# Creating a new Expense

Creates an expense.
**Bulk Create**
This endpoint supports bulk creating up to 100 objects. In the request body, set the top-level key to its plural form and place the objects in an array. Example:

```
{
  "expenses": [
    {
      "workspace_id": 123,
      "date": "2025-01-01",
      "expense_category_id": 456,
      "category": "Travel",
      "amount_in_cents": 20000
    },
    {
      "workspace_id": 123,
      "date": "2025-01-01",
      "expense_category_id": 456,
      "category": "Travel",
      "amount_in_cents": 20000
    }
  ]
}
```
This endpoint returns structured Expense objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the `results` array
and will be indexed by ID in the `expenses` top-level JSON key.
Please see our [Response Format](#section/Response-Format) section for more information.

Endpoint: POST /expenses
Version: 1.0.0

## Query parameters:

  - `include` (string)
    Any of the below associations can be included in your request by providing the `include` param, e.g. `include=association1,association2`.
- `active_submission` (ExpenseReportSubmission) - The active expense report the expense is submitted in. The response will include `active_submission_id`, which references the data in the `expense_report_submissions` top-level key.
- `expense_budget` (ExpenseBudget) - Retrieves the expense budget the expense is logged to. The response will include `expense_budget_id`, which references the data in the `expense_budgets` top-level key.
- `expense_category` (ExpenseCategory) - The category associated with the expense. The response will include `expense_category`, which references the data in the `expense_categories` top-level key.
- `external_references` (ExternalReference) - Includes references to external integrations for this object.
- `receipt` (Attachments::ReceiptAttachment) - Information about receipts associated with this expense. The response will include `receipt_id`, which references the data in the `attachments` top-level key.
- `recent_submission` (ExpenseReportSubmission) - The most recent expense report the expense was submitted in, including any rejected or cancelled reports. The response will include `recent_submission_id`, which references the data in the `expense_report_submissions` top-level key.
- `role` (Role) - The role of the user. The response will include `role_id`, which references the data in the `roles` top-level key.
- `story` (Story) - Linked task. The response will include `story_id`, which references the data in the `stories` top-level key.
- `user` (User) - The user who created the expense. The response will include `user_id`, which references the data in the `users` top-level key.
- `vendor` (Vendor) - The party to which the expense is payable. The response will include `vendor_id`, which references the data in the `vendors` top-level key.
- `workspace` (Workspace) - The project to which this expense belongs. The response will include `workspace_id`, which references the data in the `workspaces` top-level key.

  - `optional_fields` (array)
    Allows you to request one or more optional fields as an array.

## Request fields (application/json):

  - `expense` (object)

  - `expense.workspace_id` (integer, required)
    The ID of the project in which the expense will be created.

  - `expense.date` (string, required)
    The date of the expense. The date must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `expense.expense_category_id` (integer, required)
    The ID of the category with which the expense will be associated.

  - `expense.category` (string, required)
    The category of the expense as a string.

  - `expense.amount_in_cents` (integer, required)
    The amount of the expense, in cents. If 'foreign_exchange_amount' is specified, that overrides the 'amount_in_cents'.

  - `expense.foreign_exchange_amount` (object)
    If you have permission to convert expenses, this is the expense in foreign currency units.

  - `expense.foreign_exchange_amount.source_value` (string, required)
    The amount of the expense, in foreign currency units.

  - `expense.foreign_exchange_amount.source_currency` (string, required)
    The [ISO code](https://mavenlink.zendesk.com/hc/en-us/articles/360041576473-Supported-Currency-ISO-Codes) of the foreign currency in which the expense was incurred.

  - `expense.user_id` (integer)
    The internal ID of the user the expense is associated with. This parameter is ignored unless the
authorizing user has financial access in the project and is on the consultants team (or if the
authorizing user is an account administrator and has proxy permissions via an account member with
those permissions).

  - `expense.notes` (string)
    Freeform text related to the expense.

  - `expense.billable` (boolean)
    A boolean that indicates whether or not the expense is billable.

  - `expense.receipt_id` (integer)
    The optional ID of an attached receipt for the expense.

  - `expense.story_id` (integer)
    The optional ID of a task in the project (this will be linked to this expense). Depending on the
project's settings, expenses can be associated with only expense budgets or only tasks.

  - `expense.expense_budget_id` (integer)
    The optional ID of an expense budget in the project (this will be linked to this expense). Depending
on the project's settings, expenses can be associated with only expense budgets or only tasks.

  - `expense.reimbursable` (boolean)
    A boolean that indicates whether the expense is reimbursable to the user.

  - `expense.vendor_id` (integer)
    The optional ID of the vendor to which the expense is reimbursable.

  - `expense.external_reference` (object)
    Typically populated programmatically by a third party system via an integration, this is an optional
object that holds data from an external system. It connects objects in an external system with objects in
Kantata OX (for example, to connect a Jira issue to a Kantata OX Project).

  - `expense.external_reference.service_name` (string, required)
    The provider name of the integration. If you are adding multiple external references to the same object, the `service_name` must be unique.

  - `expense.external_reference.service_model` (string, required)
    The object type of the external object this external reference belongs to.

  - `expense.external_reference.service_model_ref` (string, required)
    The object ID of the external object this external reference belongs to.

  - `expense.external_reference.status` (string)
    The status of the integration. Options are `successful`, `pending`,  or `failed`.

  - `expense.external_reference.external_message` (string)
    The message on the external object.

  - `expense.external_reference.external_link` (string)
    The link to the external object.

  - `expense.external_reference.external_status` (string)
    The status of the external object in the external system.

  - `expense.external_reference.locked` (boolean)
    Whether the subject is locked.

## Response 200 fields (application/json):

  - `count` (integer)

  - `meta` (object)

  - `meta.count` (integer)

  - `meta.page_count` (integer)

  - `meta.page_number` (integer)

  - `meta.page_size` (integer)

  - `results` (array)

  - `results.key` (string)

  - `results.id` (string)

## Response 400 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 401 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 403 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 404 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 422 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 503 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

